home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-06-29 | 1.6 KB | 37 lines | [TEXT/GEOL] |
- Item 6672672 26-June-90 10:19PDT
-
- From: D2605 Xanadu Operating,Marc Stiegler,PRT
-
- To: MM.XOBJ MacroMind, Haim Zamir,PRT
-
- cc: CPLUS.DEV$ C++ Interest List--Developers
-
- Sub: Re: walking the inheritance…
-
- Haim,
- We (at Xanadu) have written a set of simple macros which we use when
- defining new classes. These macros statically create a "Category" object for
- each class we define. (We didn't use the obvious "Class" because it's
- overloaded enough for us...) We then define (as part of the macro) a
- getCategory method in each class, which returns a pointer to the statically
- defined category object. The category object maintains the name of the class
- and the superclass. This allows us to do dynamic type checking and other nifty
- stuff requiring dynamic type information. The classes aren't difficult to
- write, if you need more info, write.
- For the dynamic addition of methods, may I make a recommendation?
-
- don't.
-
- A simple way to get the effect of adding dynamic code is to define a class
- that has a simple protocol - like "value". Then, in a class where you want to
- add a function at runtime, instead add a member reference to one of these new
- classes. When you would invoke the function, instead invode the value member
- function of the new class (you can overload with different numbers of
- parameters if necessary). You will, of course, have to do some casting, but
- this is much cleaner and is portable.
-
- --Hugh Hoover
- Xanadu Operating Company, D2605
-
-
-